<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>标签新增</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css" th:href="@{css/me.css}"> <!--引入自定义CSS样式-->
</head>
<body>
    <!--导航-->
    <nav th:replace="admin/_fragments :: menu(3)" class="ui inverted attached segment me-padded-tb-mini me-shadow-small"> <!--引入css样式-->
        <div class="ui container">
            <div class="ui inverted secondary menu stackable"><!--stackable可堆叠，解决手机访问-->
                <h2 class="ui teal header item">后台管理</h2> <!--item为menu中的一个条目-->
                <a href="#" class="active m-item item me-mobile-hide"><i class="home icon"></i>博客</a><!--href为超链接-->
                <a href="#" class="m-item item me-mobile-hide"><i class="idea icon"></i>分类</a><!--m-item，在JQuery里获取样式-->
                <a href="#" class="m-item item me-mobile-hide"><i class="tags icon"></i>标签</a>

                <div class="right m-item me-mobile-hide menu">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img src="../../static/images/wechat.jpg" alt="" class="ui avatar image">
                            泽宝宝
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a href="#" class="ui black icon button me-top-right me-mobile-show menu toggle"> <!--手机端菜单图标, menu toggle获取点击事件-->            <i class="sidebar icon"></i>
        </a>
    </nav>

    <!--二级导航-->
    <div class="ui attached pointing menu"> <!--active的就可以有小箭头-->
        <div class="ui container">
            <div class="right menu">
                <a href="#" th:href="@{/admin/tags/input}" class="teal active item">新增</a>
                <a href="#" th:href="@{/admin/tags}" class="item">列表</a>
            </div>

        </div>

    </div>

    <!--中间内容-->
    <div class="me-container-small me-padded-tb-large">
        <div class="ui container">
            <form action="#" method="post" th:object="${tag}" class="ui form" th:action="*{id}==null ? @{/admin/tags} : @{/admin/tags/{id}(id=*{id})}"><!--拿到type对象-->
                <input type="hidden" name="id" th:value="*{id}" >
                <!--输入类型-->
                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">名称</label>
                        <input type="text" name="name" placeholder="标签名称" th:value="*{name}"><!--拿到name的值，为了后面编辑的-->
                    </div>
                </div>

                <!--错误信息-->
                <!--前端非空验证-->
                <div class="ui error mini message"></div> <!--为空时跳出来的提示框-->
                <!--后端非空验证-->
                <div class="ui negative message" th:if="${#fields.hasErrors('name')}">
                    <i class="close icon"></i>
                    <div class="header">验证失败</div>
                    <p th:errors="*{name}">提交信息不符合规则</p> <!--拿到name上的message注释-->
                </div>

                <!--提交、返回按钮-->
                <div class="ui right aligned container">
                    <!--onclick内容为哪里来的就返回到哪里-->
<!--                    <button class="ui button" onclick="window.history.go(-1)">返回</button>&lt;!&ndash;默认事件是提交&ndash;&gt;-->
                    <button class="ui submit teal button">提交</button><!--submit: 回车自动提交-->
                </div>
            </form>
        </div>
    </div>

    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <!--底部footer-->
    <footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment me-padded-tb-max"><!--vertical消除圆角，用attached好像也行-->
        <div class="ui center aligned container"><!--居中-->
            <div class="ui inverted divided grid stackable"><!--grid stackable默认均匀分成16份, divided分割线-->
                <div class="three wide column">
                    <div class="ui inverted link list">
                        <div class="item">
                            <img src="../../static/images/wechat.jpg" class="ui rounded image" alt="" style="width: 110px"><!--alt规定图片无法显示时的替代文本-->
                        </div>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header me-text-space me-opacity-mini">最新博客</h4><!--标题-->
                    <div class="ui inverted link list">
                        <a href="#" class="item me-text-thin me-text-lined">用户故事</a>
                        <a href="#" class="item me-text-thin me-text-lined">用户故事</a>
                        <a href="#" class="item me-text-thin me-text-lined">用户故事</a>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header me-text-space me-opacity-mini">联系我</h4><!--标题-->
                    <div class="ui inverted link list">
                        <a href="#" class="item me-text-thin me-text-lined">Email: stg1205@163.com</a>
                        <a href="#" class="item me-text-thin me-text-lined">QQ: 1014922487</a>
                    </div>
                </div>
                <div class="seven wide column">
                    <h4 class="ui inverted header me-text-space me-opacity-mini">介绍</h4>
                    <p class="me-text-space me-text-thin me-text-lined me-opacity-mini">这是我的个人博客，啦啦啦啦啦啦拉拉拉啊拉啦阿拉</p>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <p class="me-text-space me-opacity-tiny">Copyright</p>
        </div>

    </footer>

    <th:block th:replace="_fragments :: script"></th:block>

    <script>
        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('me-mobile-hide'); //toggleClass，取反函数
        });

        /*下拉框*/
        $('.ui.dropdown').dropdown({
            on: 'hover' //鼠标放上就触发
        });

        /*表单验证*/
        $('.ui.form').form({
            fields: { //要加s。。。
                name: {
                    identifier: 'name1',//与name一致
                    rules: [{
                        type: 'empty',
                        prompt: '请输入分类名称!', //提示内容
                    }]
                }
            }
        });

        //要加后面的""里的地址
        $('#newBlog-container').load(/*[[@{/footer/newBlogs}]]*/"/footer/newBlogs");
    </script>
</body>
</html>